package com.ls.aop.chain;

import java.util.ArrayList;
import java.util.List;

public class Chain {
	private int index=0;
	List<Handler> handlers=new ArrayList<>();
	public Chain() {}
	public Chain(List<Handler> handlers) {
		this.handlers=handlers;
	}
	
	public void process() {
		if(index<handlers.size()) {
			handlers.get(index++).hand();
		}
	}
	
	public void add(Handler handler) {
		handlers.add(handler);
	}
}
